USE [texchange_db]
GO

/****** Object:  StoredProcedure [dbo].[SP_GetAllLanguages]    Script Date: 05/29/2011 19:40:02 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE proc [dbo].[SP_GetAllLanguages] 
	@start  bigint=0,
	@limit bigint=30,
	@order nvarchar(10) = 'id',
	@orderdir nvarchar(4) = 'desc'
as
	DECLARE @select AS NVARCHAR(4000)
	SET @select = 'SELECT [id], [language_name], [isActive] from
			(SELECT *, ROW_NUMBER() OVER (ORDER BY id asc) AS  rownum FROM Languages) as a
		WHERE rownum >='+@start+' AND rownum<='+@limit+'
		ORDER By '+@order+' '+ @orderdir
EXEC sp_executesql @select
return




GO


